function [df, dfull, cdindex] = load_data_full(DATA)

    %%%%%%%%%%%%%%%%
    %  Basic data  %
    %%%%%%%%%%%%%%%%

    load(fullfile(DATA, 'blp_beer_revised_final.mat'));

    % ID vector
    id2 = data(:, 1);

    % Other useful id vectors
    firmid = floor(id2 / 10000000000);
    brndid = floor((id2 - firmid * 10000000000) / 100000000);
    sizeid = floor((id2 - firmid * 10000000000 - brndid*100000000) / 1000000);
    cityid = floor((id2 - firmid * 10000000000 - brndid*100000000  - sizeid*1000000) / 10000);
    yearid = floor((id2 - firmid * 10000000000 - brndid*100000000  - sizeid*1000000  - cityid * 10000) / 100);
    montid = id2 - firmid * 10000000000 - brndid * 100000000 - sizeid * 1000000 - cityid * 10000 - yearid * 100;
    obsin  = (yearid <= 3 | yearid >= 6) | (yearid == 4 & montid < 6) | (yearid == 5 & montid >= 6);

    df = array2table(id2(obsin), 'VariableNames', {'id2'});

    df.firmid      = firmid(obsin);
    df.cityid      = cityid(obsin);
    df.yearid      = yearid(obsin);
    df.sizeid      = grp2idx(sizeid(obsin));
    df.brndid      = brndid(obsin);
    df.montid      = montid(obsin);
    yearcityid     = grp2idx(df.yearid * 100 + df.cityid);
    df.dateid      = grp2idx(df.yearid * 100 + df.montid);
    df.prodid      = grp2idx(df.brndid * 100 + df.sizeid);
    df.prodcityid  = grp2idx(df.cityid * 10^ceil(log10(max(df.prodid))) + df.prodid);

    df.cdid    = grp2idx(df.cityid * 10^ceil(log10(max(df.dateid))) + df.dateid);
    cdchange   = df.cdid(1:end-1) ~= df.cdid(2:end);
    df.cdid    = cumsum([1; cdchange]);
    df.index   = (1:length(df.cdid))';
    cdindex    = df.index([cdchange; 1] == 1);

    df.firmid(df.firmid == 4) = 1;
    df.bmc = 1 * (df.firmid == 1) | (df.firmid == 5) | (df.firmid == 6);
    df.bud = 1 * (df.firmid == 1);

    % Prices; unit sales (144oz equivalents)
    df.p_jt = data(obsin == 1, 2);
    df.q_jt = data(obsin == 1, 4);

    % Market size; shares
    msize   = data(obsin == 1, 5) / 1.10;
    msize   = msize * 1.50;
    df.s_jt = df.q_jt ./ msize;

    inshr     = accumarray(df.cdid, df.s_jt);
    df.inshr  = inshr(df.cdid);
    df.outshr = 1.0 - df.inshr;

    df.s_jgt   = log(df.s_jt) - log(df.inshr);
    df.logodds = log(df.s_jt) - log(df.outshr);

    % Product characteristics
    df.import = ismember(df.brndid, [5:8]);
    df.calor  = data(obsin == 1, 6) / 100;
    df.calor  = df.calor - mean(df.calor);
    df.mcpost = (df.firmid == 06 | df.firmid == 08) & (df.yearid > 4 | (df.yearid == 4 & df.montid >= 6));

    %%%%%%%%%%%%%%%%%%
    %  Demographics  %
    %%%%%%%%%%%%%%%%%%

    ns     = 500;
    demos  = csvread(fullfile(DATA, 'demos.csv'),    1, 2);
    sumdat = csvread(fullfile(DATA, 'demosSum.csv'), 1, 2);

    % Expanding the data, removing post-merger year. Sumdat3 used below.
    inc     = demos(yearcityid, 1:ns);
    dfull   = inc - mean(mean(inc));
    df.minc = sumdat(yearcityid, 1);

    %%%%%%%%%%%%%
    %  IV Data  %
    %%%%%%%%%%%%%

    load(fullfile(DATA, 'blp_iv_revised_final.mat'));

    % BMC post-merger; distance
    df.bmcpost = data(obsin == 1, 2);
    df.dist    = data(obsin == 1, 3);
    df.cons    = ones(sum(obsin), 1);

    % Number of products and total distance
    nprod = accumarray(df.cdid, df.cons);
    tdist = accumarray(df.cdid, df.dist);
    df.nprod = nprod(df.cdid);
    df.tdist = tdist(df.cdid);
    
    % Internal instruments
    marketfirm = findgroups(df.cityid,df.yearid,df.montid,df.firmid);
    market     = findgroups(df.cityid,df.yearid,df.montid);
    obsin_own  = accumarray(marketfirm,1);
    obsin_oth  = accumarray(market,1);
    obsin_own  = obsin_own(marketfirm)-1;
    obsin_oth  = obsin_oth(market)-obsin_own-1;
    df.obsin_own  = obsin_own;
    df.obsin_oth  = obsin_oth;
    
end

